# -*- coding:iso-8859-1 -*-
#
# Copyright @2009 - Emmanuel Br&ecute;ton
#
# Licensed under the GNU General Public License, Version 3.0 (the
# "License"); you may not use this file except in compliance with the
# License.  You may obtain a copy of the License at the root of this
# project in file LICENSE.TXT
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime

from django.contrib.auth.models import User
from django.http import HttpResponseRedirect, HttpResponse, HttpResponseForbidden
from django.contrib.auth.forms import UserCreationForm

from obviews.fallbacks import HttpResponseBadRequest
from obviews.views import View, FormView, CutResponse

class DirectView(View):
    def build_params(self, request):
        raise CutResponse(HttpResponseRedirect("/polls/"))

# ACCOUNT ############################################################
class Register(FormView):
    template_name="registration/register.html"
    form_class = UserCreationForm
    
    def process_form(self, form, request, **vars):
        username = form.cleaned_data['username']
        password = form.cleaned_data['password1']
        return User.objects.create_user(username, username+u"@nomail.com", password)
